import { Stock } from 'src/server/stock/entities/stock.entity';
import { ApiProperty } from '@nestjs/swagger';
import { Base } from 'src/entities/Base';
import { Entity, Column, OneToMany, PrimaryColumn } from 'typeorm';

@Entity('product')
export class Product extends Base {
    @Column({
        name: 'enter_date',
        type: 'timestamp',
        default: () => 'CURRENT_TIMESTAMP',
        nullable: true,
        comment: '进货时间',
    })
    enterDate: Date;

    @ApiProperty()
    @Column({ name: 'creator_guid', comment: '创建人ID', default: '' })
    creatorGuid: string;

    @ApiProperty()
    // @Column({ name: 'p_id', comment: '商品ID', default: '' })
    @PrimaryColumn({ name: 'p_id', comment: '商品ID' })
    pId: string;

    @ApiProperty()
    @Column({ name: 'cover', comment: '商品图片', default: '', nullable: true })
    cover: string;

    @ApiProperty()
    @Column({ name: 'hash', comment: '图片hash值', default: '', nullable: true })
    hash: string;

    @ApiProperty()
    @Column({ name: 'p_name', comment: '商品名称', default: '', nullable: true })
    name: string;

    @ApiProperty()
    @Column({ name: 'p_ip', comment: '商品IP', default: '', nullable: true })
    pIp: string;

    @ApiProperty()
    @Column({ name: 'p_category', comment: '类别', default: 0, nullable: true })
    category: number;

    categoryDesc: string;

    @ApiProperty()
    @Column({ name: 'p_source', comment: '商品来源', default: 0, nullable: true })
    source: number;

    sourceDesc: string;

    @ApiProperty()
    @Column({ name: 'p_status', comment: '状态', default: 0, nullable: true })
    status: number;

    statusDesc: string;

    @ApiProperty()
    @Column({ name: 'box_price', type: 'decimal', comment: '整合价', default: 0, precision: 10, scale: 2 })
    boxPrice: number;

    @ApiProperty()
    @Column({ name: 'buy_price', type: 'decimal', comment: '进价', default: 0, precision: 10, scale: 2 })
    buyPrice: number;

    @ApiProperty()
    @Column({ name: 'sell_price', type: 'decimal', comment: '售价', default: 0, precision: 10, scale: 2 })
    sellPrice: number;

    @ApiProperty()
    @Column({ name: 'guide_price', type: 'decimal', comment: '指导价', default: 0, precision: 10, scale: 2 })
    guidePrice: number;

    @ApiProperty()
    @Column({ name: 'break_price', type: 'decimal', comment: '折扣价', default: 0, precision: 10, scale: 2 })
    breakPrice: number;

    @ApiProperty()
    @Column({ comment: '库存', default: 0 })
    stock: number;

    stockRecord: Stock[];
}
